﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace NGUYENMANHDUNG.OOP.Excercises3
{
    public partial class Convert_Kg : Form
    {
        public Convert_Kg()
        {
            InitializeComponent();
        }

        private void BtnConvert_Click(object sender, EventArgs e)
        {
            errorMessage.Clear();
            if (String.IsNullOrEmpty(TxtNhapSo.Text))


            {
                errorMessage.SetError(TxtNhapSo, "Vui lòng nhập số Kilogram");
                return;
            }
            else 
            {
                double Kilogram = 0;
                ConvertPounds objPounds = new ConvertPounds();
            
             
                if(!Double.TryParse(TxtNhapSo.Text, out Kilogram))
                {
            
                errorMessage.SetError(TxtNhapSo  , "Giá trị bạn nhập không đúng");
                return;
                }
                else
                {
                    listBox1.Items.Add("kilogram =" + Kilogram.ToString() + " = " + objPounds.ConvertToPounds(Kilogram) + " Pounds");
                }
            }


           
                


        }
    }
}
